function CallBack() {
	var _this = this;
	this.data = null;
	this.msg = null;
	this.status = '';
	this.success = function(fn) {
		_this._fns = fn;
		return this;
	}
	this.error = function(fn) {
		_this._fne = fn;
		return this;
	}
	this._back = function() {
		console.log('CallBack->status:' + _this.status + ', data:' + _this.data + ', msg:' + _this.msg);
		if (_this.status == 'success') {
			_this._fns.call(this, _this.data);
		} else if (_this.status == 'error') {
			_this._fne.call(this, _this.msg, _this.status);
		}
	}
	this._call = function(fn) {
		try {
			_this.data = fn.call(this, _this._callP);
			_this.status = 'success';
		} catch (e) {
			_this.status = 'error';
			_this.msg = e.message;
		}
		setTimeout(_this._back, 100);
	}
	this.kill = function(p1, p2) {
		_this._callP = {p1, p2};
		_this._call(function() {
			if (p1 == 'man' || p2 == 'man') {
				throw new Error('oh he is man');
			}
			console.log('kill ' + p1);
			console.log('kill ' + p2);
			return 'all is killed';
		});
		return this;
	}
}
function MyHttp() {
	var _this = new CallBack();
	_this.isURL = function(url) {
		return new RegExp("^(https|http)?://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$").test(url);
	}
	_this.get = function(url, param) {
		_this._callP = {url, param};
		_this._call(function() {
			if (!_this.isURL(url)) {
				throw new Error('请求地址不合法');
			}
			var kv = '?sid=';
			for (var p in param) {
				kv += '&' + p + '=' + param[p];
			}
			return url + kv;
		});
		return this;
	}
	_this.post = function(url, param) {
		return this;
	}
	_this.upload = function(file, url, param) {
		return this;
	}
	return _this;
}
